package com.syx.order.Service;

import com.syx.order.Dao.OrderMapper;
import com.syx.order.Model.OrderInfo;
import com.syx.order.Model.ProductInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class OrderService {
    @Resource
    private OrderMapper orderMapper;

    @Resource
    RestTemplate restTemplate;


    public OrderInfo selectOrderById(Integer orderId){
        OrderInfo orderInfo = orderMapper.selectOrderById(orderId);

        String url="http://127.0.0.1:9090/product/"+orderInfo.getProductId();
        ProductInfo productInfo = restTemplate.getForObject(url, ProductInfo.class);
        orderInfo.setProductInfo(productInfo);

        return orderInfo;



    }
}
